
public class Executiu extends Treballador{
	private int comissio=2;
	private int salariCarrec;
	private Comercial[] comercials = new Comercial[25];
	private Secretaria secretaria;
	private int c=0;
	
	public Executiu(String nom,String dni,String adreca){
		super(nom,dni,adreca);
		this.salariCarrec=1200;
	}
	
	public int calcularSalari(){
		int salariComisio=0;
		for (int i=0;i<this.c-1;i++)
			salariComisio+=(this.comercials[i].obtenirVendesMensuals()*this.comissio/100);
		return salariComisio+this.salariCarrec+super.calcularSalari();
	}
	
	public void fixarSalariCarrec(int salariCarrec){
		this.salariCarrec=salariCarrec;
	}
	
	public boolean afegirComercial(Comercial comercial){
		if (comercial==null) return false;
		if (comercial.teExecutiu()==true) return false;
		comercial.fixarExecutiu(this);
		this.comercials[this.c]=comercial;
		this.c++;
		return true;
	}
	
	public String LListarComercials(){
		String llistat="Comercials per al executiu "+this.obtenirNom()+":\n";
		int co;
		if (this.c==0) return "Aquest executiu no te comercials assignats.\n";
		for (int i=0;i<this.c;i++){
			co=this.comercials[i].obtenirVendesMensuals()*this.comissio/100;
			llistat+=this.comercials[i].toString()+" Comisio: "+co+".\n";
		}
		return llistat;
	}
	
	public boolean fixarSecretaria(Secretaria secretaria){
		if (secretaria.teExecutiu()==true) return false;
		secretaria.fixarExecutiu(this);
		this.secretaria=secretaria;
		return true;
	}
}
